package com.qian.ddj.web.controller;

import com.qian.api.ddj.model.Holiday;
import com.qian.api.ddj.service.IHolidayService;
import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ddj/holiday")
@Api(tags = "节假日管理")
public class HolidayController {
    @Autowired
    private IHolidayService holidayService;
    @PostMapping("/save")
    @ApiOperation("保存或修改")
    public void save(Holiday holiday){
        holidayService.saveOrUpdate(holiday);
    }
    @GetMapping("/all")
    @ApiOperation("查询所有")
    public PageResp<Holiday> findAll(PageReq pageReq){
        PageResp<Holiday> pageResp = holidayService.findAll(pageReq);
        return pageResp;
    }
    @GetMapping("/delete/{id}")
    @ApiOperation("根据ID删除")
    public void delete(@PathVariable Integer id){
        holidayService.deleteById(id);
    }
    @GetMapping("{id}")
    @ApiOperation("根据ID查询")
    public Holiday findById(@PathVariable Integer id){
       return  holidayService.findById(id);
    }
}
